package cn.smbms.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.smbms.dao.UserMapper;
import cn.smbms.pojo.User;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Resource(name="userMapper")
	@Autowired
	private UserMapper userMapper;
	
	
	
	public UserMapper getUserMapper() {
		return userMapper;
	}



	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}



	public User login(User user) {
		return userMapper.login(user);
	}

	public List<User> getUserList(String queryUserName, Integer queryUserRole, Integer currentPageNo,
			Integer pageSize) {
		currentPageNo = (currentPageNo-1)*pageSize;
		List<User> userList = userMapper.getUserList(queryUserName, queryUserRole, currentPageNo, pageSize);
		return userList;
	}



	public int getUserCount(String queryUserName, Integer queryUserRole) {
		return userMapper.getUserCount(queryUserName, queryUserRole);
	}



	public int updateUser(User user) {
		
		return userMapper.updateUser(user);
	}
	public User byidgetUser(int id) {
		
		return userMapper.byidgetUser(id);
	}


	public boolean deleteUser(int id) {
		boolean i=false;
		if(userMapper.deleteUser(id)>0) {
			i=true;
			return i;
		}else {
			
			return i;
		}
		
		
	}
	public int updatePassword(int id, String userPassword) {
		return userMapper.updatePasswordById(id, userPassword);
	}
	public User selectUserById(int id) {
		return userMapper.selectUserById(id);
	}



	public int addUser(User user) {
		
		return userMapper.addUser(user);
	}



	



	

}
